package com.experiment.aicommunityback.service.Impl;


import com.experiment.aicommunityback.entity.Result;
import com.experiment.aicommunityback.entity.ResultCodeEnum;
import com.experiment.aicommunityback.entity.dto.GoodsDTO;

import com.experiment.aicommunityback.mapper.GoodsTypeMapper;
import com.experiment.aicommunityback.service.GoodsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class GoodsTypeServiceimpl implements GoodsTypeService {

    @Autowired
    private GoodsTypeMapper goodsTypeMapper;

    @Override
    public Result getGoodsTypeAll() {
        List<GoodsDTO> GoodsDTOList = goodsTypeMapper.selectGoodsWithTypeInfo();
        Result result = Result.setResult(ResultCodeEnum.SUCCESS);
        Map<String, Object> goodsmap = new HashMap<>();
        goodsmap.put("Goods", GoodsDTOList);
        result.setData(goodsmap);
        return result;
    }




    @Override
    public Result deleteGoodsType(List<Integer> id) {
        int i = goodsTypeMapper.deleteBatchIds(id);
        return this.getGoodsTypeAll();
    }
}
